<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var obj = {
            name: 'jack',
            age: 18
        }

        var obj1 = obj;
        console.log(obj1, obj);

        obj.age = 58;
        console.log(obj1, obj);

        var a = {
            name: 'andy',
            age: 21
        }

        var b = {};
        for (var k in a) {
            b[k] = a[k];
        }
        console.log(b, a);
        a.age = 28;
        console.log(b, a);

        var stu = {
            name: 'jack',
            age: 22,
            gren: {
                name: '前端',
                source: {
                    'ppt': '路径'
                }
            }
        }

        var stu1 = {};
        for (var k in stu) {
            stu1[k] = stu[k];
            if (typeof stu[k] == 'object') {
                stu[k] = {};
                for (var key in stu[k]) {
                    stu1[k][key] = stu[k][key];
                }
            }
        }
        console.log('stu1:' + stu1.gren.name, 'stu:' + stu.gren.name);

        stu.gren.name = 'Node.js';

        console.log('stu1:' + stu1.gren.name, 'stu:' + stu.gren.name);
    </script>
</body>

</html>